package com.mmd.common.component;

public class ExceptionUtil {

	public static String getExceptionDetail(Exception e) {
		StringBuffer stringBuffer = new StringBuffer(e.toString() + "\r\n");
		stringBuffer.append("<br>");
		StackTraceElement[] messages = e.getStackTrace();
		int length = messages.length;
		for (int i = 0; i < length; i++) {
			stringBuffer.append("\t" + messages[i].toString() + "\r\n" + "<br>");
		}
		String str = stringBuffer.toString();
		if (str != null)
			str = str.replaceAll("###", "<br>###");
		return str;
	}

	public static String getExceptionDetailStr(Exception e) {
		StringBuffer stringBuffer = new StringBuffer(e.toString() + "\r\n");
		stringBuffer.append("\n");
		StackTraceElement[] messages = e.getStackTrace();
		int length = messages.length;
		for (int i = 0; i < length; i++) {
			stringBuffer.append("\t" + messages[i].toString() + "\r\n" + "\n");
		}
		String str = stringBuffer.toString();
		if (str != null)
			str = str.replaceAll("###", "\n###");
		return str;
	}
}
